<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<link rel="stylesheet" type="text/css" th:href="@{/css/index.css}">

<body>
<p class="login">用户名：</p>  <input type="text" name="name" id="name">

密码：  <input type="text" name="pwd" id="pwd">

<input type="button" id="but" name="but" value="登">
</body>


</html>

<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>

<script>
    $(function(){
        $('#but').click(function(){
            $.ajax({
                type: "post",
                url: "login",
                contentType:"application/json",
                data: JSON.stringify({name:$("#name").val(), pwd:$("#pwd").val()}),
                dataType: "json",
                success: function(data){
                    if(data.exceptionMsg === 'success'){
                        alert("登陆成功");
                        location.href="main";
                    }else{
                        alert("登陆失败");
                        location.href="index";
                    }
                }
            });
        });
    });
</script>

